<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<script type="text/javascript" src="<%=path%>/static/js/jquery-3.2.1.js"></script>
	<c:set value="${requestScope.rubbish }" var="rubbish"></c:set>
	<form action="<%=path%>/web/userinfo/saveData" type="post" id="form">
			<dl>
        <dt>名称</dt>
        <dd><input type="hidden" name="rubbish.id" value="${rubbish.id }">
        <input value="${rubbish.name }" disabled="disabled" name="name" type="text" aria-label="系统匹配废弃物名称" placeholder="系统匹配废弃物名称"></dd>
        
      </dl>
      <dl>
        <dt>所属类型</dt>
        <dd><input value="${rubbish.secondtype.title }" disabled="disabled" name="title" type="text" aria-label="匹配父级分类" placeholder="匹配父级分类"></dd>
      </dl>
       <dl>
        <dt>发生地</dt>
        <dd>
        <select name="province" id="province">
		        <c:if test="${requestScope.provinces==null }">
			        	<option value="fenlei1-1">----------------------</option>
        		</c:if>
        		<c:if test="${requestScope.provinces!=null }">
	        		<c:forEach items="${requestScope.provinces }" var="province" varStatus="stat">
	        				<option value="${province.province_ID }">${province.province_name }</option>
	        		</c:forEach>
        		</c:if>
        </select>
        <select name="city.city_ID" id="city">
        	<option value="fenlei1-1">----------------------</option>
        
        </select>
        </dd>
      </dl>
      <dl>
        <dt>起止时间</dt>
        <dd><input value="选择开始时间" name="startTime" type="text" onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}' })" id="datemin" class="input-text Wdate" style="width:120px;"></dd>
        <dd><input value="选择结束时间" name="stopTime" type="text" onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d' })" id="datemax" class="input-text Wdate" style="width:120px;"></dd>
      </dl>
      <dl id="produce">
        <dt>产生量（系统单位）</dt>
        <dd><input  id="chanSheng" name="chanSheng" type="text" aria-label="输入数值" placeholder="输入数">
        <c:if test="${rubbish.units!=null }">
	        <select name = "unit.id">
		        	<c:forEach items="${rubbish.units }" varStatus="stat" var="unit">
		        			<option value="${unit.id }">${unit.name}</option>
		        	</c:forEach> 
	        	</select> 
        	</c:if>
        </dd>
      </dl>
      <dl id="recycle">
        <dt>回收量（系统单位）</dt>
        <dd><input id="huishou" name="huiShou" type="text" aria-label="输入数值" placeholder="输入数">
         <c:if test="${rubbish.units!=null }">
        	<select name = "unit.id">
        			<c:forEach items="${rubbish.units }" varStatus="stat" var="unit">
        					<option value="${unit.id }">${unit.name}</option>
        			</c:forEach>
        	</select>
        </c:if>
        </dd>
      </dl>
      <dl> 
          <dt>备注</dt>
          <dd>
            <textarea name="content" cols="80" rows="10"></textarea>
          </dd>
        </dl>
     <!--  <dl>
        <dt>再生量（系统单位）</dt>
        <dd><input name="Number3" type="text" aria-label="输入数值" placeholder="输入数"></dd>
      </dl> -->
      <div class="submit">
          <input type="submit" name="submit" id="submit" value="提交">
           <input type="submit" name="back" id="back" value="重置">
      </div>
      </form>
  <script type="text/javascript" src="<%=path%>/static/managecss/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
  <script type="text/javascript" src="<%=path%>/static/managecss/lib/laypage/1.2/laypage.js"></script>
	<script type="text/javascript" src="<%=path%>/static/managecss/lib/layer/2.4/layer.js"></script>
	<script type="text/javascript" src="<%=path%>/static/managecss/lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="<%=path%>/static/managecss/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
	<script type="text/javascript" src="<%=path%>/static/managecss/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
	<script type="text/javascript" src="<%=path%>/static/managecss/lib/jquery.validation/1.14.0/messages_zh.js"></script> 
      
	<script type="text/javascript">
	$(function() {	
	$("#form").validate({
		rules:{
				name:{
					required:true,
					
				},
				title:{
					required:true
				
				},
			/* 	startTime:{
					required:true,
					dateISO:true
				}, */
				stopTime:{
					required:true,
					dateISO:true
				},
				chanSheng:{
					required:true
				},
				huiShou:{
					required:true,
					
				},
				content:{
					required:true				
				},
			},
			errorPlacement: function(error, element) {                             
				error.appendTo( element.parent() );                            
			},
			onkeyup:false,
			focusCleanup:true,
			success:"valid"
	});		
});
	
	
	
	 	$(function() {
		
		$("#huishou").blur(function() {
			
			if($("#huishou").val()!=""){
				$("#produce").css("display","none")
			}
			if($("#huishou").val()==""){
				$("#produce").css("display","block")
			} 
		});
		$("#chanSheng").blur(function() {
		
		 	if($("#chanSheng").val()!=""){
				$("#recycle").css("display","none")
			}
			if($("#chanSheng").val()==""){
				$("#recycle").css("display","block")
			} 
		});
	}); 
	
	
	
	
			$(function() {
				var f = ${requestScope.provinces!=null };
				if(f){
					initCity();
				}
				
					$("#province").change(initCity);
				
			})
			
			
			function initCity() {
		
				var provinceId = $("#province").val();
				$("#city").empty();
		
				$.ajax({
							type : "POST",
							url : "<%=path%>/web/userinfo/findAllByProvinceId",
							data : "provinceId="+provinceId,
							dataType:"json",
							success : function(city) {
							
								
							 for(var i=0;i<city.length;i++)
							 {
							 	$("#city").append("<option value=\""+city[i].city_ID+"\">"+city[i].city_name+"</option>");				 	
							 }	
							}
						}); 
					}
			
			/* 撤销所有 */
			$(function() {
				$("#back").click(function() {
				
					$("input[type!=submit]").val("");
				})		
			})
			
	
	</script>
	
	
	
	
	
	
	
	
	
	
	
	
	
	